PSC 8101 Lab, Wed., Sept. 4, 2024
| Name | vdem$v2x_polyarchy |
| Number of rows | 179 |
| Number of columns | 1 |
| _______________________ | |
| Column type frequency: | |
| numeric | 1 |
| ________________________ | |
| Group variables | None |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| data | 0 | 1 | 0.52 | 0.25 | 0.02 | 0.29 | 0.52 | 0.75 | 0.91 | ▃▆▆▆▇ |
| Name | vdem |
| Number of rows | 179 |
| Number of columns | 4171 |
| _______________________ | |
| Column type frequency: | |
| numeric | 1 |
| ________________________ | |
| Group variables | None |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| v2x_polyarchy | 0 | 1 | 0.52 | 0.25 | 0.02 | 0.29 | 0.52 | 0.75 | 0.91 | ▃▆▆▆▇ |
# We can also report y-axis in percentage terms; the third line uses
# the "scales" package
# also, label axes, give title
ggplot(data = weather, mapping = aes(x = temp)) +
geom_histogram(aes(y = (..count..)/sum(..count..)), binwidth = 2.029083, color = "white") +
scale_y_continuous(labels=percent) +
labs(x="Temperature", y="Percentage of Hours", title="Temperatures")# Now change labeling for y-axis values
ggplot(data = weather, mapping = aes(x = temp)) +
geom_histogram(aes(y = (..count..)/sum(..count..)), binwidth = 2.029083, color = "white") +
scale_y_continuous(limits = c(0, .06), breaks = seq(0, .06, by = .01), labels=percent) +
labs(x="Temperature", y="Percentage of Hours", title="Temperatures")# Change theme for graph background
# Now change labeling for y-axis values
ggplot(data = weather, mapping = aes(x = temp)) +
geom_histogram(aes(y = (..count..)/sum(..count..)), binwidth = 2.029083, color = "white") +
scale_y_continuous(limits = c(0, .06), breaks = seq(0, .06, by = .01), labels=percent) +
labs(x="Temperature", y="Percentage of Hours", title="Temperatures") +
theme_minimal()# Center title
ggplot(data = weather, mapping = aes(x = temp)) +
geom_histogram(aes(y = (..count..)/sum(..count..)), binwidth = 2.029083, color = "white") +
scale_y_continuous(limits = c(0, .06), breaks = seq(0, .06, by = .01), labels=percent) +
labs(x="Temperature", y="Percentage of Hours", title="Temperatures") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))# Ridge plots
# Notice I have to change month to "factor" variable. Most variables are "continuous"
# by default. I need to change this to "discrete" or ggplot can't graph it like
# I want it to.
ggplot(weather, aes(x = temp, y=factor(month))) +
geom_density_ridges(fill="dodgerblue", alpha=.5) +
labs(x="Temperature", y="Month", title="Temperatures") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))# We could get a frequency distribution in table form using the
# "freq" command from the questionr package.
freq(flights$carrier) n % val%
9E 18460 5.5 5.5
AA 32729 9.7 9.7
AS 714 0.2 0.2
B6 54635 16.2 16.2
DL 48110 14.3 14.3
EV 54173 16.1 16.1
F9 685 0.2 0.2
FL 3260 1.0 1.0
HA 342 0.1 0.1
MQ 26397 7.8 7.8
OO 32 0.0 0.0
UA 58665 17.4 17.4
US 20536 6.1 6.1
VX 5162 1.5 1.5
WN 12275 3.6 3.6
YV 601 0.2 0.2